package com.fhz.day013jetpackall.utils;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.fhz.day013jetpackall.dao.BannerDao;
import com.fhz.day013jetpackall.entity.Banner;

/**
 * 时间:2022/5/31
 *
 * @author msfeng
 * 简述: TODO
 */
@Database(entities = Banner.class,version = 1,exportSchema = false)
public abstract class MyDatabase extends RoomDatabase {

    private static MyDatabase myDatabase;

    public abstract BannerDao bannerDao();

    public static MyDatabase getMyDatabase(Context context){
        if(myDatabase == null){
            myDatabase = Room.databaseBuilder(context,MyDatabase.class,"shop")
                    .allowMainThreadQueries()
                    .build();
        }
        return myDatabase;
    }

}

